<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/crypto-js/3.1.9-1/crypto-js.min.js"></script>
    <script type="text/javascript">

        var encryptResult = encrypt("a123456");
        console.log("加密 " + encryptResult);
        var decryptResult = decrypt(encryptResult);
        console.log("解密 " + decryptResult);
        /**
         * 加密
         * @param word
         * @returns {*}
         */
        function encrypt(word) {
            var key = CryptoJS.enc.Utf8.parse("!WD#WA@WSSCJY321");
            var srcs = CryptoJS.enc.Utf8.parse(word);
            var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
            return encrypted.toString();
        }

        /**
         * 解密
         * @param word
         * @returns {*}
         */
        function decrypt(word) {
            var key = CryptoJS.enc.Utf8.parse("!WD#WA@WSSCJY321");
            var decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
            return CryptoJS.enc.Utf8.stringify(decrypt).toString();
        }
    </script>
</head>
<body>

</body>
</html>